home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / tex / spell.ml < prev    next >
Encoding:
Text File  |  1986-02-14  |  1.9 KB  |  73 lines

  1. ; This is a version of spell, originally written by Gosling but
  2. ;hacked by Harrison.
  3. ;The changes are that if there be some misspelled word or abbreviation
  4. ;which the spell routine returns as an error, say ''cs''. In some
  5. ;occurrences, this may be an error, in others an abbreviation, and in
  6. ;others a legitimate subword like in ``topics''.
  7. ;When prompted, hit e to exit.
  8. ;              r to go into a query-replace loop
  9. ;            n takes you to the next occurrence of the word; if there
  10. ;             is none, you pick up the next error. 
  11.  
  12.  
  13. (defun
  14.     (correct-spelling-mistakes word action continue further
  15.     (setq continue 1)
  16.     (progn
  17.         (while continue
  18.         (save-excursion
  19.             (get)
  20.         )
  21.         (beginning-of-file)
  22.         (setq further 1)    ; go further to find location of error
  23.         (while further            ; go looking for occurrence
  24.             (setq further 0); reset to no-further
  25.             (if (error-occured(search-forward word))
  26.             (progn
  27.                 (message (concat "No further occurrences of " word " found!" ))
  28.                 (sit-for 10)
  29.             )
  30.             (progn
  31.                 (message  (concat word " ? "))
  32.                 (setq action (get-tty-character))
  33.                 (if
  34.                 (= action 'e') (setq continue 0)
  35.                 (= action 'n') (setq further 1)    ; search for more
  36.                 (= action 'r') (progn
  37.                            (beginning-of-line)
  38.                            (error-occured
  39.                                (query-replace-string word
  40.                                (get-tty-string
  41.                                    (concat word " => "))))
  42.                            )
  43.                 )
  44.             )
  45.             )
  46.         )
  47.         )
  48.     )
  49.     (novalue)
  50.     )
  51.     (get
  52.     (temp-use-buffer "Error log")
  53.     (beginning-of-file)
  54.     (set-mark)
  55.     (end-of-line)
  56.     (setq word (region-to-string))
  57.     (forward-character)
  58.     (delete-to-killbuffer)
  59.     )
  60. )
  61. (defun 
  62.     (spell
  63.     (message (concat "Looking for errors in " (current-file-name)
  64.              ", please wait..."))
  65.     (sit-for 0)
  66.     (save-excursion
  67.         (compile-it (concat "cat " (current-file-name) " | detex | spell ")))
  68.     (error-occured (correct-spelling-mistakes))
  69.     (message "Done!")
  70.     (novalue)
  71.     )
  72. )
  73.